package cadc.actions;

import cadc.daos.EntrantDao;
import cadc.daos.FileItemDao;
import cadc.daos.GroupDao;
import cadc.models.Group;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class ViewGroupInfo extends ActionSupport {
	
	private int groupId;
	private Group group;
	private GroupDao groupDao;
	private EntrantDao entrantDao;
	private FileItemDao fileItemDao;
	private String workType;
	
	private static String[] typenames = {"学习平台->学习交流网站",
		"学习平台->数据库管理系统",
		"学习平台->CAI教学课件",
		"学习平台->虚拟实验平台",
		"媒体设计->平面设计",
		"媒体设计->动画设计",
		"媒体设计->虚拟设计(人物、场景等)",
		"媒体设计->DV短剧",
		"媒体设计->电子杂志",
		"媒体设计->其他",
		"电子音乐->电子音乐",
		"媒体制作设计类->中华民族文化组"};
	
	public String execute(){
		group = groupDao.getBasicInfo(groupId);
		if(group==null)return SUCCESS;
		if(group.getFirstMem().getId()>0)group.setFirstMem(entrantDao.getEntrantById((int)group.getFirstMem().getId()));
		if(group.getSecondMem().getId()>0)group.setSecondMem(entrantDao.getEntrantById((int)group.getSecondMem().getId()));
		if(group.getThirdMem().getId()>0)group.setThirdMem(entrantDao.getEntrantById((int)group.getThirdMem().getId()));
		if(group.getTeacher().getId()>0)group.setTeacher(entrantDao.getEntrantById((int)group.getTeacher().getId()));
		if(group.getWork().getId()>0){
			group.setWork(fileItemDao.getFileItemById((int) group.getWork().getId()));
			workType = typenames[group.getWorkType()];
		}
		else group.getWork().setItemFileName("未上传");
		return SUCCESS;
	}
	
	public void setGroup(Group group) {
		this.group = group;
	}
	public Group getGroup() {
		return group;
	}
	public void setGroupDao(GroupDao groupDao) {
		this.groupDao = groupDao;
	}
	public GroupDao getGroupDao() {
		return groupDao;
	}
	public void setEntrantDao(EntrantDao entrantDao) {
		this.entrantDao = entrantDao;
	}
	public EntrantDao getEntrantDao() {
		return entrantDao;
	}

	public void setFileItemDao(FileItemDao fileItemDao) {
		this.fileItemDao = fileItemDao;
	}

	public FileItemDao getFileItemDao() {
		return fileItemDao;
	}

	public int getGroupId() {
		return groupId;
	}

	public void setGroupId(int groupId) {
		this.groupId = groupId;
	}

	public String getWorkType() {
		return workType;
	}

	public void setWorkType(String workType) {
		this.workType = workType;
	}
}
